import { QXEvent } from "qx-util";
import { IParam, DashboardActionType, IDashboardAbility, IDashboardControllerParams, IDashboardStore, DashboardController, ICtrlEvent, IDashboardController, IDashboardModel } from "@/core";
import { useDashboardAction, useDashboardBasic, useDashboardControllerParams, useDashboardProps } from "@/hooks/widget/use-dashboard";
import { model } from "./app-portal-view-2-db-dashboard-model";
// 基于template/src/widgets/{{appEntities}}/{{ctrls@DASHBOARD}}-dashboard/{{spinalCase ctrl.codeName}}-dashboard-hook.ts.hbs生成
/**
 * 获取输入参数
 *
 * @export
 * @return {*}
 */
export function useProps() {
	return {
		...useDashboardProps(),
	};
}

/**
 * 获取基础数据
 *
 * @export
 * @param {*} props
 * @return {*}
 */
export function useBasic(props: any) {
	return {
		...useDashboardBasic(model, props),
	};
}

/**
 * 获取行为
 *
 * @export
 */
export function useAction(controller: any) {
	return {
		...useDashboardAction(controller),
	};
}

/**
 * 获取控制器
 *
 * @export
 * @param {IParam} props
 * @param {QXEvent<ICtrlEvent<DashboardActionType, IDashboardAbility>>} evt
 * @return {*}
 */
export function useController(
	props: IParam,
	evt: QXEvent<ICtrlEvent<DashboardActionType, IDashboardAbility>>,
    otherParams: IParam = {},
): IDashboardController<IDashboardStore, IDashboardAbility> {
	const params: IDashboardControllerParams<DashboardActionType, IDashboardAbility> =
		useDashboardControllerParams<IDashboardStore, IDashboardModel>(model, props, evt, otherParams);
  	return new DashboardController(params);
}